package com.longjianghuasheng.logistics.business.mine.fragment

import android.os.Bundle
import com.longjianghuasheng.logistics.R
import com.longjianghuasheng.logistics.base.BaseTitleFragment
import com.longjianghuasheng.logistics.business.mine.adapter.ProblemAdapter
import com.longjianghuasheng.logistics.business.mine.viewmodel.CommonProblemViewModel
import com.longjianghuasheng.logistics.databinding.FragmentCommonProblemBinding
import com.longjianghuasheng.logistics.ext.initLinerDecoration
import com.longjianghuasheng.logistics.ext.observer

class CommonProblemFragment :
    BaseTitleFragment<CommonProblemViewModel, FragmentCommonProblemBinding>() {

    private val problemAdapter by lazy {
        ProblemAdapter()
    }

    override fun layoutId(): Int = R.layout.fragment_common_problem

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        initTitleBar("常见问题")
        problemAdapter.run {

            mDatabind.rvProblem.initLinerDecoration(space = 0F, adapter = problemAdapter)

            listener = {
                navigate(R.id.aboutFragment, Bundle().apply {
                    putInt("id", data[it].id ?: 0)
                    putBoolean("isProblem", true)
                })
            }


        }
    }

    override fun createObserver() {
        super.createObserver()
        mViewModel.result.observer(this) {
            problemAdapter.setNewInstance(it.data)

        }
    }

    override fun initData() {
        super.initData()
    }

    override fun lazyLoadData() {
        super.lazyLoadData()
        mViewModel.help_list()
    }

}